<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta charset="utf-8">
<title>发布买盘</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<script>BASE_URL = '${request.getContextPath()}'</script>
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css">

<link href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css" id="style_components" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/css/plugins.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/layout.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color">
<link href="${request.getContextPath()}/Public/assets/admin/css/custom.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/admin/css/common.css" rel="stylesheet" type="text/css">



<link rel="shortcut icon" href="${request.getContextPath()}/Public/favicon.ico">
<!--[if lt IE 9]>
<script src="${request.getContextPath()}/Public/assets/global/plugins/respond.min.js"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>

<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery.sparkline.min.js" type="text/javascript"></script>



<script src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js" type="text/javascript"></script>
<!-- <script src="${request.getContextPath()}/Public/assets/admin/scripts/indexComponent.js" type="text/javascript"></script> -->
<script src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js" type="text/javascript"></script>


<!-- select2控件 -->
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.js"></script>
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2_locale_zh-CN.js"></script>
<link href="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.css" rel="stylesheet" type="text/css">

<!-- 日期控件 
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery.ui.datepicker.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery.ui.datepicker-zh-CN.js" type="text/javascript"></script>
-->
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.zh-CN.min.js" type="text/javascript"></script>

<!-- 数据验证 -->
<script src="${request.getContextPath()}/Public/assets/global/plugins/jquery-validation/js/jquery.validate.js" type="text/javascript"></script>

</head>
<body class="page-header-top-fixed">
<div class="page-header">
	<!--头部开始-->
	<#include "/include/top.html" />
	<!-- 头部信息结束 -->

	<!-- 头部菜单开始 -->
	<#include "/include/top_menu.html" />
	<!-- 头部菜单结束 -->
</div>
<!-- END HEADER -->
<div class="page-container">
	<div class="page-content">
		<div class="container-fluid">
			<ul class="page-breadcrumb breadcrumb">
				<li>
					<a href="#">首页</a><i class="fa fa-circle"></i>
				</li>
				<li class="active">
					撮合管理<i class="fa fa-circle"></i>
				</li>
				<li class="active">
					买盘池
				</li>
				<li class="active">
					 发布买盘
				</li>
			</ul>
			<div class="row margin-top-10">
				<div class="col-md-12">
					<div class="portlet light bordered" align="center">
						<form class="form-horizontal" id="buypublish">
						  <div class="form-group">
						  	  <p align="left"><h3 style="font-weight: bold;">发布买盘</h3></p> <br><br>
						  	 <input type="hidden" name="id" value="${buypool.id}">
						  	 <input  type="hidden" name="companyID" value="${buypool.companyID}"/>
						  	 <input  type="hidden" id="companyNm" name="companyNm" value="${buypool.companyname}"/>	
						  	 <input type="hidden" id="contact" name="contact">					  	 
						  <div class="form-group">
						    <label  class="col-sm-2 control-label">商城用户名</label>
						    <div class="col-sm-2">
						     <select class="form-control"  style="width: 200px" id="account"  name="account" onchange="viewContact(this)">						      
						      </select>
						    </div>
						    <div id="" class="col-sm-2">
						      <p><span>联系人:</span><span id="contact1"  style="color: RED"></span></p>
						    </div>
						    <div id="telephone" class="col-sm-2">
						      <p><span>电话：</span><span id="telephone1" style="color: RED"></span></p>
						    </div>
						  </div>
						</div>
						  <div class="form-group">
						    <label  class="col-sm-2 control-label">挂牌有效期：</label>
						    <div class="col-sm-2">
						      <select  class="form-control" id="dates" onchange="zdate()"  name="unit">
						      <option value="1">当天</option>
						      <option value="2">本周</option>
						      <option value="3">本月</option>
						      <option value="4">三月</option>
						      <option value="5">半年</option>
						      <option value="0">指定时间</option>
						      </select><font id="s1" style="display:none; ">  <input  id ="optionalDate" style="height: 35px;width: 240px;"   class="form-control"  name="validitydate"/> </font>
					   		 </div>
						  </div>
							<#list attrvaluelist as attr>
						  <div class="form-group">
						    <label  class="col-sm-2 control-label">${attr.attrName}：</label>
						    <div class="col-sm-2">
						    <input  type="text" readonly="readonly" name="" value="${attr.attrValue}"/>
						    </div>
						  </div>
						  </#list>
						  <div class="form-group">
						    <label  class="col-sm-2 control-label">数量：</label>
						    <div class="col-sm-2">
						       <input type="text" class="form-control" id="quantity" name="quantity">
						    </div>
						  </div>
						 						  <div class="form-group">
						    <div   class="col-sm-offset-2 col-sm-10">
						    	<button id="Button"  onclick="javascript :history.back(-1);" type="button" class="btn green pull-left">
									返回 <i class="m-icon-swapright m-icon-white"></i>
								</button>
						      	<button type="button"  id="savetButton" class="btn green pull-left">
									提交<i class="m-icon-swapright m-icon-white"></i>
								</button>
						    </div>
						  </div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 底部开始 -->
<#include "/include/foot.html" />
<!-- 底部结束 -->
</body>
<script>
	
jQuery(document).ready(function() {
	   
	
	
	
		 
		 $("#optionalDate").datepicker({
		   	 	language: "zh-CN",
		        autoclose: true,//选中之后自动隐藏日期选择框
		        clearBtn: true,//清除按钮
		        todayBtn: true,//今日按钮
		        format: "yyyy-mm-dd",//日期格式
		        startDate:new Date()
			});
	
	   
	recordDate();
	//初始化日期
	function recordDate() {
		var nowDate = new Date();
        //$('#date-picker').attr("date-date",nowDate.getFullYear()+"/"+parseInt(nowDate.getMonth()+1)+"/"+nowDate.getDate());
        $('.date-picker').datepicker({
    	    autoclose: true	   
    	});
        
        
	}
	
	
	 //商城
	 $("#account").empty();
		$.ajax({
			url : "${request.getContextPath()}/dealMake/queryCompany.do",
			type : "post",
			dataType:"json",
			async: false,
			data :{"companyName":$("#companyNm").val()}, //联动查询的字符
			success : function(data) {
			 	var jsonData = eval(data);//接收到的数据转化为JQuery对象，由JQuery为我们处理 
				$("#account").append("<option value=''>--请选择--</option>");
				$.each(jsonData, function(index, item) {
					$("#account").append(
							"<option value='"+item.userid+"'myAttr1='"+item.truename+"'myAttr2='"+item.mobile+"'>" + item.account + "</option>");
				}); 
			}
		});
	
	
	   Metronic.init(); // init metronic core componets
	   Layout.init(); // init layout
	});
	
	$("#savetButton").bind("click",function(){
		
	var com = document.getElementById("account").value;
		
		if(com==null||com==""){
			
			alert("请选择商城");
			return;
		}
		
	
	       var obj = document.getElementById("quantity");
	    if( obj.value==null|| obj.value=="" || obj.value<=0){
	        alert("数量必须大于0!");
	        return;
	        
	    }

		$.ajax({
			url : "${request.getContextPath()}/buypool/buypublish.do",
			type : "post",
			dataType:"json",
			async: false,
			data : $("#buypublish").serialize(),
			success : function(result) {
			
			      		window.location.href="${request.getContextPath()}/buypool/buylist.do";
		
			   }
		});
	});
	

	
	function resultFormatResult(medata) {
        return medata.text; 
	} 
	      
	function resultFormatSelection(medata) {
	        return medata.text; 
	} 
	
	
	function quit(){
		
  		window.location.href="${request.getContextPath()}/buypool/buylist.do";

	}
	
	function zdate(){
		
		var vals=document.getElementById("dates").value;
		
		if(vals==0){
		
			document.getElementById("s1").style.display="block";
			
		}else{
			document.getElementById("s1").style.display="none";

			
		}
		
	}
	
	//下拉框选中触发
	function viewContact(object){
		 	var obj=document.getElementById("account");    
		    var index=obj.selectedIndex;   
		    var myAttr1=obj.options[index].getAttribute("myAttr1");//联系人
		    var myAttr2=obj.options[index].getAttribute("myAttr2");//电话
		    
		  //追加联系人数据
			document.getElementById("contact1").innerHTML = myAttr1;
			$("#contact").val(myAttr1);
			document.getElementById("telephone1").innerHTML = myAttr2;
	}

	function resultFormatResult(medata) {
       return medata.text; 
	} 
	     
	
	
	function resultFormatSelection(medata) {
		//追加联系人数据
	
			document.getElementById("contact1").innerHTML = medata.truename;
			$("#contact").val(medata.truename);
			document.getElementById("telephone1").innerHTML = medata.mobile;
	        return medata.text; 
	} 
	

</script>
</html>

